from pyPLNmodels import load_scrna
rna = load_scrna(dim=20)
print('Data: ', rna.keys())Returning scRNA dataset of size (400, 20)
Data: dict_keys(['endog', 'labels', 'labels_1hot'])
This guide introduces the basics of multivariate count data analysis using the pyPLNmodels package. For complex datasets, traditional models like Poisson regression and Zero-Inflated Poisson Regression (ZIP) may fail to capture important insights, such as correlations between counts (i.e. variables). The pyPLNmodels package provides two key models to address these challenges:
Pln model (documentation)PlnPCA model (documentation)The PlnPCA model extends the functionality of the Pln model to handle high-dimensional data, though it may slightly compromise parameter estimation accuracy.
Both models are built on the following assumptions for a given count matrix \(Y\) (Aitchison and Ho 1989):
\[ Y_{ij}| Z_{ij} \sim \mathcal P(\exp(o_{ij} + Z_{ij})), \quad Z_{i}\sim \mathcal N(X_i^{\top} B, \Sigma),\] where the input data includes:
endog): the \(j\)-th count for the \(i\)-th observationexog): covariates for the \(i\)-th observation (if available)offsets): offset for the \(i\)-th observation (if available)and the model parameters are:
coef): a matrix of regression coefficientscovariance): the covariance matrix of the latent variables \(Z_i\)These models aim to capture the structure of the data through the latent variables \(Z\).
The Pln model assumes \(\Sigma\) has full rank, while the PlnPCA model assumes \(\Sigma\) has a low rank, which must be specified by the user. A lower A lower rank introduces a trade-off, reducing computational complexity but potentially compromising parameter estimation accuracy.
The pyPLNmodels package is designed to:
This is achieved using the input count matrix \(Y\), along with optional covariate matrix \(X\) (defaulting to a vector of 1’s) and offsets \(O\) (defaulting to a matrix of 0’s).
In this example, we analyze single-cell RNA-seq data provided by the load_scrna function in the package. Each column in the dataset represents a gene, while each row corresponds to a cell (i.e., an individual). Covariates for cell types (labels) are also included. For simplicity, we limit the analysis to 20 variables (dimensions).
from pyPLNmodels import load_scrna
rna = load_scrna(dim=20)
print('Data: ', rna.keys())Returning scRNA dataset of size (400, 20)
Data: dict_keys(['endog', 'labels', 'labels_1hot'])
endog)endog = rna["endog"]
print(endog.head()) FTL MALAT1 FTH1 TMSB4X CD74 SPP1 APOE B2M ACTB HLA-DRA \
0 5.0 39.0 14.0 39.0 11.0 0.0 0.0 88.0 49.0 0.0
1 8.0 52.0 38.0 186.0 17.0 0.0 0.0 152.0 167.0 3.0
2 76.0 29.0 38.0 71.0 37.0 3.0 2.0 21.0 7.0 12.0
3 354.0 151.0 236.0 184.0 287.0 0.0 238.0 255.0 27.0 243.0
4 0.0 55.0 10.0 37.0 8.0 1.0 0.0 23.0 49.0 1.0
APOC1 MT-CO1 TMSB10 EEF1A1 HLA-DRB1 HLA-DPA1 HLA-DPB1 MT-CO2 LYZ \
0 0.0 29.0 22.0 34.0 0.0 0.0 1.0 21.0 0.0
1 0.0 109.0 65.0 128.0 2.0 4.0 1.0 172.0 1.0
2 3.0 46.0 7.0 11.0 0.0 7.0 17.0 16.0 0.0
3 196.0 118.0 45.0 98.0 66.0 115.0 160.0 27.0 6.0
4 0.0 11.0 25.0 10.0 1.0 2.0 2.0 6.0 0.0
RPLP1
0 14.0
1 124.0
2 20.0
3 40.0
4 18.0
cell_type = rna["labels"]
print('Possible cell types: ', cell_type.unique())
print(cell_type.head())Possible cell types: ['T_cells_CD4+' 'Macrophages' 'T_cells_CD8+']
0 T_cells_CD4+
1 T_cells_CD4+
2 Macrophages
3 Macrophages
4 T_cells_CD4+
Name: standard_true_celltype_v5, dtype: object
To analyze the mean values for each cell type, we use cell type as a covariate, with Macrophages as the reference category:
from pyPLNmodels import Pln
pln = Pln.from_formula('endog ~ 1 + labels', data=rna).fit()Setting the offsets to zero.
Fitting a Pln model with full covariance.
Intializing parameters ...
Initialization finished.
Maximum number of iterations (400) reached in 7.5 seconds.
Last criterion = 5.4e-06 . Required tolerance = 1e-06
Upper bound on the fitting time: 0%| | 0/400 [00:00<?, ?it/s]Upper bound on the fitting time: 2%|▎ | 10/400 [00:00<00:04, 95.55it/s]Upper bound on the fitting time: 5%|▌ | 21/400 [00:00<00:03, 102.53it/s]Upper bound on the fitting time: 8%|▊ | 33/400 [00:00<00:03, 109.23it/s]Upper bound on the fitting time: 11%|█▏ | 45/400 [00:00<00:03, 111.44it/s]Upper bound on the fitting time: 14%|█▍ | 58/400 [00:00<00:02, 114.85it/s]Upper bound on the fitting time: 18%|█▊ | 70/400 [00:00<00:02, 115.31it/s]Upper bound on the fitting time: 20%|██ | 82/400 [00:00<00:02, 115.02it/s]Upper bound on the fitting time: 24%|██▎ | 94/400 [00:00<00:02, 114.20it/s]Upper bound on the fitting time: 26%|██▋ | 106/400 [00:00<00:02, 114.03it/s]Upper bound on the fitting time: 30%|██▉ | 118/400 [00:01<00:02, 99.25it/s] Upper bound on the fitting time: 32%|███▏ | 129/400 [00:01<00:03, 86.56it/s]Upper bound on the fitting time: 35%|███▍ | 139/400 [00:01<00:03, 83.30it/s]Upper bound on the fitting time: 37%|███▋ | 148/400 [00:01<00:03, 80.70it/s]Upper bound on the fitting time: 39%|███▉ | 157/400 [00:01<00:03, 80.22it/s]Upper bound on the fitting time: 42%|████▏ | 168/400 [00:01<00:02, 87.05it/s]Upper bound on the fitting time: 45%|████▍ | 179/400 [00:01<00:02, 93.03it/s]Upper bound on the fitting time: 48%|████▊ | 190/400 [00:01<00:02, 96.50it/s]Upper bound on the fitting time: 50%|█████ | 200/400 [00:02<00:02, 92.92it/s]Upper bound on the fitting time: 52%|█████▎ | 210/400 [00:02<00:02, 94.61it/s]Upper bound on the fitting time: 55%|█████▌ | 220/400 [00:02<00:01, 94.91it/s]Upper bound on the fitting time: 57%|█████▊ | 230/400 [00:02<00:01, 89.68it/s]Upper bound on the fitting time: 60%|██████ | 240/400 [00:02<00:01, 85.54it/s]Upper bound on the fitting time: 62%|██████▎ | 250/400 [00:02<00:01, 87.47it/s]Upper bound on the fitting time: 65%|██████▌ | 260/400 [00:02<00:01, 89.10it/s]Upper bound on the fitting time: 68%|██████▊ | 271/400 [00:02<00:01, 94.51it/s]Upper bound on the fitting time: 70%|███████ | 281/400 [00:02<00:01, 92.03it/s]Upper bound on the fitting time: 73%|███████▎ | 292/400 [00:03<00:01, 96.12it/s]Upper bound on the fitting time: 76%|███████▌ | 304/400 [00:03<00:00, 100.62it/s]Upper bound on the fitting time: 79%|███████▉ | 316/400 [00:03<00:00, 103.97it/s]Upper bound on the fitting time: 82%|████████▏ | 328/400 [00:03<00:00, 107.59it/s]Upper bound on the fitting time: 85%|████████▌ | 340/400 [00:03<00:00, 110.70it/s]Upper bound on the fitting time: 88%|████████▊ | 352/400 [00:03<00:00, 112.28it/s]Upper bound on the fitting time: 91%|█████████ | 364/400 [00:03<00:00, 108.71it/s]Upper bound on the fitting time: 94%|█████████▍| 375/400 [00:03<00:00, 103.19it/s]Upper bound on the fitting time: 96%|█████████▋| 386/400 [00:03<00:00, 99.63it/s] Upper bound on the fitting time: 100%|█████████▉| 398/400 [00:04<00:00, 103.19it/s]Upper bound on the fitting time: 100%|██████████| 400/400 [00:04<00:00, 98.38it/s]
For more details on formula syntax and model initialization, including handling offsets, refer to the dedicated tutorial.
After fitting the model, you can print its configuration and key details:
print(pln)A multivariate Pln with full covariance.
======================================================================
Loglike Dimension Nb param BIC AIC ICL
-22468.19 20 270 23277.0352 22738.1875 10228.37
======================================================================
* Useful attributes
.latent_variables .latent_positions .coef .covariance .precision .model_parameters .latent_parameters .optim_details
* Useful methods
.transform() .show() .predict() .sigma() .projected_latent_variables() .plot_correlation_circle() .biplot() .viz() .pca_pairplot() .plot_expected_vs_true()
* Additional attributes for Pln are:
None
* Additional methods for Pln are:
.get_variance_coef() .get_confidence_interval_coef() .summary() .get_coef_p_values() .plot_regression_forest()
To gain deeper insights into the model parameters and the optimization process, use the .show() method:
pln.show()Monitoring the norm of each parameters allows to know if the model has converged. If it has not converged, one can refit the model with a lower tolerance (tol) and a bigger number iterations than the default (maxiter=400):
pln.fit(maxiter=1000, tol = 0)The latent variables \(Z\), which capture the underlying structure of the data, are accessible via the latent_variables attribute, or the .transform() method:
Z = pln.latent_variables
Z = pln.transform()
print('Shape of Z:', Z.shape)Shape of Z: torch.Size([400, 20])
The effect of covariates on the latent variables can be removed by using the remove_exog_effect keyword:
Z_moins_XB = pln.transform(remove_exog_effect=True)You can visualize these latent variables using the .viz() method:
pln.viz(colors=cell_type)To visualize the latent positions without the effect of covariates (i.e., (Z - XB)), set the remove_exog_effect parameter to True:
pln.viz(colors=cell_type, remove_exog_effect=True)Additionally, you can generate a pair plot of the first Principal Components (PCs) of the latent variables:
pln.pca_pairplot(n_components=4, colors=cell_type)The model provides insights into the effects of covariates. For example, it may reveal that the mean value for Macrophages is higher compared to T_cells_CD4+ and T_cells_CD8+.
To summarize the model, including confidence intervals and p-values, use the summary method:
pln.summary()Coefficients and p-values per dimension:
Dimension: FTL
Exog Name Coefficient P-value
Intercept 4.405430 1e-16
labels[T.T_cells_CD4+] -3.238307 3.4e-14
labels[T.T_cells_CD8+] -3.691690 1e-16
Dimension: MALAT1
Exog Name Coefficient P-value
Intercept 4.494294 1e-16
labels[T.T_cells_CD4+] 0.047518 0.67
labels[T.T_cells_CD8+] -0.599757 0.00068
Dimension: FTH1
Exog Name Coefficient P-value
Intercept 3.977555 1e-16
labels[T.T_cells_CD4+] -2.103544 1e-16
labels[T.T_cells_CD8+] -3.101902 1e-16
Dimension: TMSB4X
Exog Name Coefficient P-value
Intercept 4.323444 1e-16
labels[T.T_cells_CD4+] -0.844740 3.6e-10
labels[T.T_cells_CD8+] -1.232170 4.2e-07
Dimension: CD74
Exog Name Coefficient P-value
Intercept 3.900579 1e-16
labels[T.T_cells_CD4+] -3.254608 1e-16
labels[T.T_cells_CD8+] -3.284683 1e-16
Dimension: SPP1
Exog Name Coefficient P-value
Intercept 0.200535 0.21
labels[T.T_cells_CD4+] -4.434213 1e-16
labels[T.T_cells_CD8+] -5.076484 1e-16
Dimension: APOE
Exog Name Coefficient P-value
Intercept 0.917977 8.2e-11
labels[T.T_cells_CD4+] -4.270944 1e-16
labels[T.T_cells_CD8+] -4.561553 1e-16
Dimension: B2M
Exog Name Coefficient P-value
Intercept 3.903286 1e-16
labels[T.T_cells_CD4+] -0.207227 0.19
labels[T.T_cells_CD8+] -0.571121 0.011
Dimension: ACTB
Exog Name Coefficient P-value
Intercept 3.477508 1e-16
labels[T.T_cells_CD4+] -1.058260 1.3e-05
labels[T.T_cells_CD8+] -1.433466 1e-16
Dimension: HLA-DRA
Exog Name Coefficient P-value
Intercept 3.569291 1e-16
labels[T.T_cells_CD4+] -4.681176 1e-16
labels[T.T_cells_CD8+] -4.322145 1e-16
Dimension: APOC1
Exog Name Coefficient P-value
Intercept 0.537658 0.00021
labels[T.T_cells_CD4+] -4.180346 1e-16
labels[T.T_cells_CD8+] -4.951382 1e-16
Dimension: MT-CO1
Exog Name Coefficient P-value
Intercept 3.719430 1e-16
labels[T.T_cells_CD4+] -0.864605 0.046
labels[T.T_cells_CD8+] -1.318557 1e-16
Dimension: TMSB10
Exog Name Coefficient P-value
Intercept 3.296484 1e-16
labels[T.T_cells_CD4+] -1.006131 0.033
labels[T.T_cells_CD8+] -1.902974 1e-16
Dimension: EEF1A1
Exog Name Coefficient P-value
Intercept 2.992825 1e-16
labels[T.T_cells_CD4+] 0.042000 0.71
labels[T.T_cells_CD8+] -1.093768 2.4e-15
Dimension: HLA-DRB1
Exog Name Coefficient P-value
Intercept 2.854607 1e-16
labels[T.T_cells_CD4+] -4.098247 1e-16
labels[T.T_cells_CD8+] -3.645638 1e-16
Dimension: HLA-DPA1
Exog Name Coefficient P-value
Intercept 2.543715 4.4e-16
labels[T.T_cells_CD4+] -3.681852 1e-16
labels[T.T_cells_CD8+] -3.447149 1e-16
Dimension: HLA-DPB1
Exog Name Coefficient P-value
Intercept 2.700437 4.9e-08
labels[T.T_cells_CD4+] -3.689348 1e-16
labels[T.T_cells_CD8+] -3.355143 1e-16
Dimension: MT-CO2
Exog Name Coefficient P-value
Intercept 2.992518 8.1e-09
labels[T.T_cells_CD4+] -0.491286 0.0016
labels[T.T_cells_CD8+] -0.978666 2.2e-16
Dimension: LYZ
Exog Name Coefficient P-value
Intercept 2.074273 9e-12
labels[T.T_cells_CD4+] -4.863344 1e-16
labels[T.T_cells_CD8+] -5.335721 1e-16
Dimension: RPLP1
Exog Name Coefficient P-value
Intercept 3.192550 4.3e-14
labels[T.T_cells_CD4+] -0.150987 0.28
labels[T.T_cells_CD8+] -0.957494 2.3e-11
You can also visualize confidence intervals for regression coefficients using the plot_regression_forest method:
pln.plot_regression_forest()The pyPLNmodels package provides tools to analyze the effects of variables and visualize their relationships using the plot_correlation_circle() and biplot() methods.
Use the plot_correlation_circle() method to visualize the relationships between variables:
pln.plot_correlation_circle(column_names=["FTL", "MALAT1", "FTH1"])You can access the column names using the column_names_endog attribute of the model.
The biplot() method allows simultaneous visualization of variables and latent variables ((Z)):
pln.biplot(column_names=["FTL", "MALAT1", "FTH1"], colors=cell_type)PlnPCA ModelThe PlnPCA model (Chiquet, Mariadassou, and Robin 2018) extends the functionality of the Pln model for high-dimensional data. It uses the same syntax as Pln:
from pyPLNmodels import PlnPCA
high_d_rna = load_scrna(dim=500)
pca = PlnPCA.from_formula('endog ~ 1 + labels', data=high_d_rna, rank=5).fit()Returning scRNA dataset of size (400, 500)
Setting the offsets to zero.
Fitting a PlnPCA model with 5 principal components.
Intializing parameters ...
Initialization finished.
Maximum number of iterations (400) reached in 8.8 seconds.
Last criterion = 5.4e-06 . Required tolerance = 1e-06
Upper bound on the fitting time: 0%| | 0/400 [00:00<?, ?it/s]Upper bound on the fitting time: 1%|▏ | 5/400 [00:00<00:07, 49.64it/s]Upper bound on the fitting time: 2%|▎ | 10/400 [00:00<00:08, 46.61it/s]Upper bound on the fitting time: 4%|▍ | 15/400 [00:00<00:08, 47.07it/s]Upper bound on the fitting time: 6%|▌ | 22/400 [00:00<00:06, 54.05it/s]Upper bound on the fitting time: 7%|▋ | 29/400 [00:00<00:06, 57.32it/s]Upper bound on the fitting time: 9%|▉ | 37/400 [00:00<00:05, 64.25it/s]Upper bound on the fitting time: 11%|█▏ | 45/400 [00:00<00:05, 69.14it/s]Upper bound on the fitting time: 13%|█▎ | 53/400 [00:00<00:04, 70.96it/s]Upper bound on the fitting time: 15%|█▌ | 61/400 [00:00<00:04, 71.18it/s]Upper bound on the fitting time: 17%|█▋ | 69/400 [00:01<00:04, 70.57it/s]Upper bound on the fitting time: 19%|█▉ | 77/400 [00:01<00:04, 68.81it/s]Upper bound on the fitting time: 21%|██▏ | 85/400 [00:01<00:04, 69.43it/s]Upper bound on the fitting time: 23%|██▎ | 93/400 [00:01<00:04, 70.44it/s]Upper bound on the fitting time: 25%|██▌ | 101/400 [00:01<00:04, 70.62it/s]Upper bound on the fitting time: 27%|██▋ | 109/400 [00:01<00:04, 71.22it/s]Upper bound on the fitting time: 29%|██▉ | 117/400 [00:01<00:04, 68.06it/s]Upper bound on the fitting time: 31%|███▏ | 125/400 [00:01<00:03, 69.58it/s]Upper bound on the fitting time: 33%|███▎ | 133/400 [00:01<00:03, 70.26it/s]Upper bound on the fitting time: 35%|███▌ | 141/400 [00:02<00:04, 63.34it/s]Upper bound on the fitting time: 37%|███▋ | 148/400 [00:02<00:04, 59.50it/s]Upper bound on the fitting time: 39%|███▉ | 155/400 [00:02<00:03, 61.46it/s]Upper bound on the fitting time: 40%|████ | 162/400 [00:02<00:03, 59.98it/s]Upper bound on the fitting time: 42%|████▏ | 169/400 [00:02<00:03, 62.25it/s]Upper bound on the fitting time: 44%|████▍ | 177/400 [00:02<00:03, 65.01it/s]Upper bound on the fitting time: 46%|████▌ | 184/400 [00:02<00:03, 65.64it/s]Upper bound on the fitting time: 48%|████▊ | 191/400 [00:02<00:03, 66.81it/s]Upper bound on the fitting time: 50%|████▉ | 199/400 [00:03<00:02, 68.41it/s]Upper bound on the fitting time: 52%|█████▏ | 207/400 [00:03<00:02, 69.32it/s]Upper bound on the fitting time: 54%|█████▎ | 214/400 [00:03<00:02, 68.30it/s]Upper bound on the fitting time: 55%|█████▌ | 221/400 [00:03<00:02, 65.94it/s]Upper bound on the fitting time: 57%|█████▋ | 228/400 [00:03<00:02, 66.97it/s]Upper bound on the fitting time: 59%|█████▉ | 236/400 [00:03<00:02, 68.13it/s]Upper bound on the fitting time: 61%|██████ | 243/400 [00:03<00:02, 67.02it/s]Upper bound on the fitting time: 62%|██████▎ | 250/400 [00:03<00:02, 64.58it/s]Upper bound on the fitting time: 64%|██████▍ | 258/400 [00:03<00:02, 66.66it/s]Upper bound on the fitting time: 66%|██████▋ | 266/400 [00:04<00:01, 68.64it/s]Upper bound on the fitting time: 68%|██████▊ | 274/400 [00:04<00:01, 69.64it/s]Upper bound on the fitting time: 70%|███████ | 281/400 [00:04<00:01, 67.92it/s]Upper bound on the fitting time: 72%|███████▏ | 288/400 [00:04<00:01, 68.10it/s]Upper bound on the fitting time: 74%|███████▍ | 295/400 [00:04<00:01, 65.90it/s]Upper bound on the fitting time: 76%|███████▌ | 302/400 [00:04<00:01, 64.41it/s]Upper bound on the fitting time: 77%|███████▋ | 309/400 [00:04<00:01, 62.09it/s]Upper bound on the fitting time: 79%|███████▉ | 316/400 [00:04<00:01, 60.54it/s]Upper bound on the fitting time: 81%|████████ | 323/400 [00:04<00:01, 60.90it/s]Upper bound on the fitting time: 82%|████████▎ | 330/400 [00:05<00:01, 61.10it/s]Upper bound on the fitting time: 84%|████████▍ | 337/400 [00:05<00:01, 60.21it/s]Upper bound on the fitting time: 86%|████████▌ | 344/400 [00:05<00:00, 61.70it/s]Upper bound on the fitting time: 88%|████████▊ | 351/400 [00:05<00:00, 62.94it/s]Upper bound on the fitting time: 90%|████████▉ | 358/400 [00:05<00:00, 63.61it/s]Upper bound on the fitting time: 91%|█████████▏| 365/400 [00:05<00:00, 64.85it/s]Upper bound on the fitting time: 93%|█████████▎| 372/400 [00:05<00:00, 65.31it/s]Upper bound on the fitting time: 95%|█████████▍| 379/400 [00:05<00:00, 64.53it/s]Upper bound on the fitting time: 96%|█████████▋| 386/400 [00:05<00:00, 62.68it/s]Upper bound on the fitting time: 98%|█████████▊| 393/400 [00:06<00:00, 63.65it/s]Upper bound on the fitting time: 100%|██████████| 400/400 [00:06<00:00, 63.30it/s]Upper bound on the fitting time: 100%|██████████| 400/400 [00:06<00:00, 64.90it/s]
⚠️ Note: P-values are not available in the PlnPCA model.
print(pca)A multivariate PlnPCA with 5 principal components.
======================================================================
Loglike Dimension Nb param BIC AIC ICL
-330635.25 500 3990 342588.2218 334625.25 339734.6
======================================================================
* Useful attributes
.latent_variables .latent_positions .coef .covariance .precision .model_parameters .latent_parameters .optim_details
* Useful methods
.transform() .show() .predict() .sigma() .projected_latent_variables() .plot_correlation_circle() .biplot() .viz() .pca_pairplot() .plot_expected_vs_true()
* Additional attributes for PlnPCA are:
None
* Additional methods for PlnPCA are:
None
This model is particularly efficient for high-dimensional datasets, offering significantly reduced computation time compared to Pln:
The rank is a hyperparameter that can be specified by the user. Alternatively, a data-driven approach to rank selection can be performed using the PlnPCACollection class, which fits multiple models with different ranks:
from pyPLNmodels import PlnPCACollection
pcas = PlnPCACollection.from_formula('endog ~ 1 + labels', data=high_d_rna, ranks=[3, 5, 10, 15]).fit()Setting the offsets to zero.
Adjusting 4 PlnPCA models.
Fitting a PlnPCA model with 3 principal components.
Intializing parameters ...
Initialization finished.
Maximum number of iterations (400) reached in 8.4 seconds.
Last criterion = 5.4e-06 . Required tolerance = 1e-06
Fitting a PlnPCA model with 5 principal components.
Intializing parameters ...
Initialization finished.
Maximum number of iterations (400) reached in 7.4 seconds.
Last criterion = 5.4e-06 . Required tolerance = 1e-06
Fitting a PlnPCA model with 10 principal components.
Intializing parameters ...
Initialization finished.
Maximum number of iterations (400) reached in 6.6 seconds.
Last criterion = 5.4e-06 . Required tolerance = 1e-06
Fitting a PlnPCA model with 15 principal components.
Intializing parameters ...
Initialization finished.
Maximum number of iterations (400) reached in 6.7 seconds.
Last criterion = 5.4e-06 . Required tolerance = 1e-06
======================================================================
DONE!
Best model (lower BIC): rank 15
Best model(lower AIC): rank 15
======================================================================
Upper bound on the fitting time: 0%| | 0/400 [00:00<?, ?it/s]Upper bound on the fitting time: 2%|▏ | 8/400 [00:00<00:04, 79.98it/s]Upper bound on the fitting time: 4%|▍ | 16/400 [00:00<00:05, 75.33it/s]Upper bound on the fitting time: 6%|▌ | 24/400 [00:00<00:05, 73.80it/s]Upper bound on the fitting time: 8%|▊ | 32/400 [00:00<00:04, 73.69it/s]Upper bound on the fitting time: 10%|█ | 40/400 [00:00<00:04, 73.49it/s]Upper bound on the fitting time: 12%|█▏ | 48/400 [00:00<00:04, 73.99it/s]Upper bound on the fitting time: 14%|█▍ | 56/400 [00:00<00:04, 73.51it/s]Upper bound on the fitting time: 16%|█▌ | 64/400 [00:00<00:04, 68.43it/s]Upper bound on the fitting time: 18%|█▊ | 71/400 [00:00<00:04, 68.46it/s]Upper bound on the fitting time: 20%|█▉ | 78/400 [00:01<00:04, 68.70it/s]Upper bound on the fitting time: 21%|██▏ | 85/400 [00:01<00:04, 68.93it/s]Upper bound on the fitting time: 23%|██▎ | 93/400 [00:01<00:04, 69.52it/s]Upper bound on the fitting time: 25%|██▌ | 100/400 [00:01<00:04, 69.43it/s]Upper bound on the fitting time: 27%|██▋ | 107/400 [00:01<00:04, 68.68it/s]Upper bound on the fitting time: 28%|██▊ | 114/400 [00:01<00:04, 66.86it/s]Upper bound on the fitting time: 30%|███ | 121/400 [00:01<00:04, 63.79it/s]Upper bound on the fitting time: 32%|███▏ | 128/400 [00:01<00:04, 63.56it/s]Upper bound on the fitting time: 34%|███▍ | 135/400 [00:01<00:04, 62.92it/s]Upper bound on the fitting time: 36%|███▌ | 142/400 [00:02<00:04, 60.48it/s]Upper bound on the fitting time: 37%|███▋ | 149/400 [00:02<00:04, 60.77it/s]Upper bound on the fitting time: 39%|███▉ | 156/400 [00:02<00:04, 60.26it/s]Upper bound on the fitting time: 41%|████ | 163/400 [00:02<00:03, 61.64it/s]Upper bound on the fitting time: 42%|████▎ | 170/400 [00:02<00:03, 62.53it/s]Upper bound on the fitting time: 44%|████▍ | 177/400 [00:02<00:03, 63.40it/s]Upper bound on the fitting time: 46%|████▌ | 184/400 [00:02<00:03, 64.96it/s]Upper bound on the fitting time: 48%|████▊ | 191/400 [00:02<00:03, 64.37it/s]Upper bound on the fitting time: 50%|████▉ | 198/400 [00:02<00:03, 65.22it/s]Upper bound on the fitting time: 51%|█████▏ | 205/400 [00:03<00:03, 61.19it/s]Upper bound on the fitting time: 53%|█████▎ | 212/400 [00:03<00:03, 59.58it/s]Upper bound on the fitting time: 55%|█████▍ | 219/400 [00:03<00:03, 60.11it/s]Upper bound on the fitting time: 56%|█████▋ | 226/400 [00:03<00:02, 60.29it/s]Upper bound on the fitting time: 58%|█████▊ | 233/400 [00:03<00:02, 61.24it/s]Upper bound on the fitting time: 60%|██████ | 240/400 [00:03<00:02, 58.77it/s]Upper bound on the fitting time: 62%|██████▏ | 246/400 [00:03<00:02, 56.61it/s]Upper bound on the fitting time: 63%|██████▎ | 253/400 [00:03<00:02, 59.88it/s]Upper bound on the fitting time: 65%|██████▌ | 261/400 [00:04<00:02, 64.26it/s]Upper bound on the fitting time: 67%|██████▋ | 269/400 [00:04<00:01, 66.03it/s]Upper bound on the fitting time: 69%|██████▉ | 276/400 [00:04<00:01, 66.33it/s]Upper bound on the fitting time: 71%|███████ | 283/400 [00:04<00:01, 67.03it/s]Upper bound on the fitting time: 72%|███████▎ | 290/400 [00:04<00:01, 66.99it/s]Upper bound on the fitting time: 74%|███████▍ | 297/400 [00:04<00:01, 67.56it/s]Upper bound on the fitting time: 76%|███████▋ | 305/400 [00:04<00:01, 68.49it/s]Upper bound on the fitting time: 78%|███████▊ | 313/400 [00:04<00:01, 69.42it/s]Upper bound on the fitting time: 80%|████████ | 321/400 [00:04<00:01, 69.92it/s]Upper bound on the fitting time: 82%|████████▏ | 329/400 [00:04<00:01, 70.26it/s]Upper bound on the fitting time: 84%|████████▍ | 337/400 [00:05<00:00, 69.96it/s]Upper bound on the fitting time: 86%|████████▋ | 345/400 [00:05<00:00, 70.40it/s]Upper bound on the fitting time: 88%|████████▊ | 353/400 [00:05<00:00, 70.98it/s]Upper bound on the fitting time: 90%|█████████ | 361/400 [00:05<00:00, 71.05it/s]Upper bound on the fitting time: 92%|█████████▏| 369/400 [00:05<00:00, 71.84it/s]Upper bound on the fitting time: 94%|█████████▍| 377/400 [00:05<00:00, 71.77it/s]Upper bound on the fitting time: 96%|█████████▋| 385/400 [00:05<00:00, 70.64it/s]Upper bound on the fitting time: 98%|█████████▊| 393/400 [00:05<00:00, 71.22it/s]Upper bound on the fitting time: 100%|██████████| 400/400 [00:05<00:00, 66.78it/s]
Upper bound on the fitting time: 0%| | 0/400 [00:00<?, ?it/s]Upper bound on the fitting time: 2%|▏ | 8/400 [00:00<00:05, 73.73it/s]Upper bound on the fitting time: 4%|▍ | 16/400 [00:00<00:05, 69.99it/s]Upper bound on the fitting time: 6%|▌ | 24/400 [00:00<00:05, 68.64it/s]Upper bound on the fitting time: 8%|▊ | 32/400 [00:00<00:05, 69.73it/s]Upper bound on the fitting time: 10%|█ | 40/400 [00:00<00:05, 70.28it/s]Upper bound on the fitting time: 12%|█▏ | 48/400 [00:00<00:04, 70.87it/s]Upper bound on the fitting time: 14%|█▍ | 56/400 [00:00<00:04, 70.38it/s]Upper bound on the fitting time: 16%|█▌ | 64/400 [00:00<00:05, 65.66it/s]Upper bound on the fitting time: 18%|█▊ | 71/400 [00:01<00:05, 59.03it/s]Upper bound on the fitting time: 20%|█▉ | 78/400 [00:01<00:05, 54.67it/s]Upper bound on the fitting time: 21%|██ | 84/400 [00:01<00:05, 53.99it/s]Upper bound on the fitting time: 22%|██▎ | 90/400 [00:01<00:05, 53.95it/s]Upper bound on the fitting time: 24%|██▍ | 96/400 [00:01<00:05, 54.29it/s]Upper bound on the fitting time: 26%|██▌ | 102/400 [00:01<00:05, 54.18it/s]Upper bound on the fitting time: 27%|██▋ | 108/400 [00:01<00:05, 52.68it/s]Upper bound on the fitting time: 28%|██▊ | 114/400 [00:01<00:05, 51.82it/s]Upper bound on the fitting time: 30%|███ | 120/400 [00:02<00:05, 51.13it/s]Upper bound on the fitting time: 32%|███▏ | 126/400 [00:02<00:05, 53.10it/s]Upper bound on the fitting time: 33%|███▎ | 133/400 [00:02<00:04, 57.65it/s]Upper bound on the fitting time: 35%|███▌ | 141/400 [00:02<00:04, 61.47it/s]Upper bound on the fitting time: 37%|███▋ | 148/400 [00:02<00:03, 63.80it/s]Upper bound on the fitting time: 39%|███▉ | 156/400 [00:02<00:03, 66.27it/s]Upper bound on the fitting time: 41%|████ | 163/400 [00:02<00:03, 67.13it/s]Upper bound on the fitting time: 42%|████▎ | 170/400 [00:02<00:03, 67.58it/s]Upper bound on the fitting time: 44%|████▍ | 177/400 [00:02<00:03, 67.88it/s]Upper bound on the fitting time: 46%|████▌ | 184/400 [00:02<00:03, 67.81it/s]Upper bound on the fitting time: 48%|████▊ | 191/400 [00:03<00:03, 68.02it/s]Upper bound on the fitting time: 50%|████▉ | 198/400 [00:03<00:02, 68.06it/s]Upper bound on the fitting time: 51%|█████▏ | 205/400 [00:03<00:02, 67.03it/s]Upper bound on the fitting time: 53%|█████▎ | 213/400 [00:03<00:02, 69.02it/s]Upper bound on the fitting time: 55%|█████▌ | 220/400 [00:03<00:02, 69.13it/s]Upper bound on the fitting time: 57%|█████▋ | 227/400 [00:03<00:02, 69.14it/s]Upper bound on the fitting time: 58%|█████▊ | 234/400 [00:03<00:02, 68.51it/s]Upper bound on the fitting time: 60%|██████ | 241/400 [00:03<00:02, 64.67it/s]Upper bound on the fitting time: 62%|██████▏ | 248/400 [00:03<00:02, 57.18it/s]Upper bound on the fitting time: 64%|██████▎ | 254/400 [00:04<00:02, 50.75it/s]Upper bound on the fitting time: 65%|██████▌ | 260/400 [00:04<00:03, 41.43it/s]Upper bound on the fitting time: 66%|██████▋ | 266/400 [00:04<00:03, 44.11it/s]Upper bound on the fitting time: 68%|██████▊ | 272/400 [00:04<00:02, 46.26it/s]Upper bound on the fitting time: 69%|██████▉ | 277/400 [00:04<00:02, 44.99it/s]Upper bound on the fitting time: 71%|███████ | 283/400 [00:04<00:02, 45.79it/s]Upper bound on the fitting time: 72%|███████▏ | 289/400 [00:04<00:02, 47.26it/s]Upper bound on the fitting time: 74%|███████▎ | 294/400 [00:05<00:02, 46.92it/s]Upper bound on the fitting time: 75%|███████▍ | 299/400 [00:05<00:02, 46.12it/s]Upper bound on the fitting time: 76%|███████▌ | 304/400 [00:05<00:02, 40.45it/s]Upper bound on the fitting time: 77%|███████▋ | 309/400 [00:05<00:02, 37.80it/s]Upper bound on the fitting time: 78%|███████▊ | 313/400 [00:05<00:02, 29.12it/s]Upper bound on the fitting time: 79%|███████▉ | 317/400 [00:05<00:03, 26.32it/s]Upper bound on the fitting time: 80%|████████ | 321/400 [00:06<00:02, 28.01it/s]Upper bound on the fitting time: 81%|████████▏ | 325/400 [00:06<00:02, 28.90it/s]Upper bound on the fitting time: 82%|████████▏ | 329/400 [00:06<00:02, 29.64it/s]Upper bound on the fitting time: 83%|████████▎ | 333/400 [00:06<00:02, 31.76it/s]Upper bound on the fitting time: 85%|████████▍ | 339/400 [00:06<00:01, 38.29it/s]Upper bound on the fitting time: 87%|████████▋ | 347/400 [00:06<00:01, 47.88it/s]Upper bound on the fitting time: 89%|████████▉ | 355/400 [00:06<00:00, 55.06it/s]Upper bound on the fitting time: 91%|█████████ | 363/400 [00:06<00:00, 60.63it/s]Upper bound on the fitting time: 92%|█████████▎| 370/400 [00:06<00:00, 62.54it/s]Upper bound on the fitting time: 94%|█████████▍| 377/400 [00:07<00:00, 62.26it/s]Upper bound on the fitting time: 96%|█████████▋| 385/400 [00:07<00:00, 66.00it/s]Upper bound on the fitting time: 98%|█████████▊| 393/400 [00:07<00:00, 67.38it/s]Upper bound on the fitting time: 100%|██████████| 400/400 [00:07<00:00, 54.35it/s]
Upper bound on the fitting time: 0%| | 0/400 [00:00<?, ?it/s]Upper bound on the fitting time: 2%|▏ | 7/400 [00:00<00:06, 64.75it/s]Upper bound on the fitting time: 4%|▎ | 14/400 [00:00<00:05, 66.49it/s]Upper bound on the fitting time: 5%|▌ | 21/400 [00:00<00:05, 65.74it/s]Upper bound on the fitting time: 7%|▋ | 28/400 [00:00<00:05, 65.09it/s]Upper bound on the fitting time: 9%|▉ | 35/400 [00:00<00:05, 65.63it/s]Upper bound on the fitting time: 10%|█ | 42/400 [00:00<00:05, 65.98it/s]Upper bound on the fitting time: 12%|█▏ | 49/400 [00:00<00:05, 66.86it/s]Upper bound on the fitting time: 14%|█▍ | 56/400 [00:00<00:05, 66.17it/s]Upper bound on the fitting time: 16%|█▌ | 63/400 [00:00<00:05, 65.85it/s]Upper bound on the fitting time: 18%|█▊ | 70/400 [00:01<00:04, 66.12it/s]Upper bound on the fitting time: 19%|█▉ | 77/400 [00:01<00:04, 65.82it/s]Upper bound on the fitting time: 21%|██ | 84/400 [00:01<00:04, 66.14it/s]Upper bound on the fitting time: 23%|██▎ | 91/400 [00:01<00:04, 66.55it/s]Upper bound on the fitting time: 24%|██▍ | 98/400 [00:01<00:04, 65.66it/s]Upper bound on the fitting time: 26%|██▋ | 105/400 [00:01<00:04, 66.41it/s]Upper bound on the fitting time: 28%|██▊ | 112/400 [00:01<00:04, 66.56it/s]Upper bound on the fitting time: 30%|██▉ | 119/400 [00:01<00:04, 66.99it/s]Upper bound on the fitting time: 32%|███▏ | 126/400 [00:01<00:04, 67.27it/s]Upper bound on the fitting time: 33%|███▎ | 133/400 [00:02<00:03, 66.80it/s]Upper bound on the fitting time: 35%|███▌ | 140/400 [00:02<00:03, 65.62it/s]Upper bound on the fitting time: 37%|███▋ | 147/400 [00:02<00:03, 65.71it/s]Upper bound on the fitting time: 38%|███▊ | 154/400 [00:02<00:03, 65.41it/s]Upper bound on the fitting time: 40%|████ | 161/400 [00:02<00:03, 64.30it/s]Upper bound on the fitting time: 42%|████▏ | 168/400 [00:02<00:03, 64.69it/s]Upper bound on the fitting time: 44%|████▍ | 175/400 [00:02<00:03, 65.21it/s]Upper bound on the fitting time: 46%|████▌ | 182/400 [00:02<00:03, 66.00it/s]Upper bound on the fitting time: 47%|████▋ | 189/400 [00:02<00:03, 66.51it/s]Upper bound on the fitting time: 49%|████▉ | 196/400 [00:02<00:03, 64.95it/s]Upper bound on the fitting time: 51%|█████ | 203/400 [00:03<00:03, 61.59it/s]Upper bound on the fitting time: 52%|█████▎ | 210/400 [00:03<00:03, 60.64it/s]Upper bound on the fitting time: 54%|█████▍ | 217/400 [00:03<00:02, 62.47it/s]Upper bound on the fitting time: 56%|█████▌ | 224/400 [00:03<00:02, 62.62it/s]Upper bound on the fitting time: 58%|█████▊ | 231/400 [00:03<00:02, 61.94it/s]Upper bound on the fitting time: 60%|█████▉ | 238/400 [00:03<00:02, 61.64it/s]Upper bound on the fitting time: 61%|██████▏ | 245/400 [00:03<00:02, 62.66it/s]Upper bound on the fitting time: 63%|██████▎ | 252/400 [00:03<00:02, 63.99it/s]Upper bound on the fitting time: 65%|██████▍ | 259/400 [00:03<00:02, 65.21it/s]Upper bound on the fitting time: 66%|██████▋ | 266/400 [00:04<00:02, 64.97it/s]Upper bound on the fitting time: 68%|██████▊ | 273/400 [00:04<00:02, 61.90it/s]Upper bound on the fitting time: 70%|███████ | 280/400 [00:04<00:01, 62.39it/s]Upper bound on the fitting time: 72%|███████▏ | 287/400 [00:04<00:01, 61.41it/s]Upper bound on the fitting time: 74%|███████▎ | 294/400 [00:04<00:01, 61.45it/s]Upper bound on the fitting time: 75%|███████▌ | 301/400 [00:04<00:01, 60.84it/s]Upper bound on the fitting time: 77%|███████▋ | 308/400 [00:04<00:01, 58.51it/s]Upper bound on the fitting time: 79%|███████▉ | 315/400 [00:04<00:01, 59.68it/s]Upper bound on the fitting time: 80%|████████ | 321/400 [00:05<00:01, 58.90it/s]Upper bound on the fitting time: 82%|████████▏ | 327/400 [00:05<00:01, 57.26it/s]Upper bound on the fitting time: 83%|████████▎ | 333/400 [00:05<00:01, 56.56it/s]Upper bound on the fitting time: 85%|████████▍ | 339/400 [00:05<00:01, 54.56it/s]Upper bound on the fitting time: 86%|████████▋ | 345/400 [00:05<00:01, 52.33it/s]Upper bound on the fitting time: 88%|████████▊ | 351/400 [00:05<00:00, 52.03it/s]Upper bound on the fitting time: 89%|████████▉ | 357/400 [00:05<00:00, 52.65it/s]Upper bound on the fitting time: 91%|█████████ | 363/400 [00:05<00:00, 51.48it/s]Upper bound on the fitting time: 92%|█████████▏| 369/400 [00:05<00:00, 52.09it/s]Upper bound on the fitting time: 94%|█████████▍| 375/400 [00:06<00:00, 52.18it/s]Upper bound on the fitting time: 95%|█████████▌| 381/400 [00:06<00:00, 51.28it/s]Upper bound on the fitting time: 97%|█████████▋| 387/400 [00:06<00:00, 53.25it/s]Upper bound on the fitting time: 98%|█████████▊| 393/400 [00:06<00:00, 53.69it/s]Upper bound on the fitting time: 100%|█████████▉| 399/400 [00:06<00:00, 52.29it/s]Upper bound on the fitting time: 100%|██████████| 400/400 [00:06<00:00, 61.09it/s]
Upper bound on the fitting time: 0%| | 0/400 [00:00<?, ?it/s]Upper bound on the fitting time: 1%|▏ | 5/400 [00:00<00:08, 47.87it/s]Upper bound on the fitting time: 3%|▎ | 11/400 [00:00<00:07, 52.67it/s]Upper bound on the fitting time: 4%|▍ | 17/400 [00:00<00:07, 53.91it/s]Upper bound on the fitting time: 6%|▌ | 23/400 [00:00<00:06, 55.25it/s]Upper bound on the fitting time: 7%|▋ | 29/400 [00:00<00:06, 55.08it/s]Upper bound on the fitting time: 9%|▉ | 35/400 [00:00<00:06, 55.38it/s]Upper bound on the fitting time: 10%|█ | 41/400 [00:00<00:06, 55.97it/s]Upper bound on the fitting time: 12%|█▏ | 47/400 [00:00<00:06, 56.97it/s]Upper bound on the fitting time: 13%|█▎ | 53/400 [00:00<00:06, 55.88it/s]Upper bound on the fitting time: 15%|█▍ | 59/400 [00:01<00:06, 56.02it/s]Upper bound on the fitting time: 16%|█▋ | 65/400 [00:01<00:06, 55.06it/s]Upper bound on the fitting time: 18%|█▊ | 71/400 [00:01<00:06, 53.55it/s]Upper bound on the fitting time: 19%|█▉ | 77/400 [00:01<00:06, 53.27it/s]Upper bound on the fitting time: 21%|██ | 83/400 [00:01<00:05, 53.24it/s]Upper bound on the fitting time: 22%|██▏ | 89/400 [00:01<00:05, 52.94it/s]Upper bound on the fitting time: 24%|██▍ | 95/400 [00:01<00:05, 52.60it/s]Upper bound on the fitting time: 25%|██▌ | 101/400 [00:01<00:05, 50.69it/s]Upper bound on the fitting time: 27%|██▋ | 107/400 [00:01<00:05, 52.07it/s]Upper bound on the fitting time: 28%|██▊ | 114/400 [00:02<00:05, 55.52it/s]Upper bound on the fitting time: 30%|███ | 121/400 [00:02<00:04, 58.23it/s]Upper bound on the fitting time: 32%|███▏ | 128/400 [00:02<00:04, 59.53it/s]Upper bound on the fitting time: 34%|███▍ | 135/400 [00:02<00:04, 59.91it/s]Upper bound on the fitting time: 36%|███▌ | 142/400 [00:02<00:04, 60.16it/s]Upper bound on the fitting time: 37%|███▋ | 149/400 [00:02<00:04, 61.65it/s]Upper bound on the fitting time: 39%|███▉ | 156/400 [00:02<00:03, 61.00it/s]Upper bound on the fitting time: 41%|████ | 163/400 [00:02<00:03, 60.83it/s]Upper bound on the fitting time: 42%|████▎ | 170/400 [00:03<00:03, 60.98it/s]Upper bound on the fitting time: 44%|████▍ | 177/400 [00:03<00:03, 60.18it/s]Upper bound on the fitting time: 46%|████▌ | 184/400 [00:03<00:03, 61.20it/s]Upper bound on the fitting time: 48%|████▊ | 191/400 [00:03<00:03, 61.43it/s]Upper bound on the fitting time: 50%|████▉ | 198/400 [00:03<00:03, 61.96it/s]Upper bound on the fitting time: 51%|█████▏ | 205/400 [00:03<00:03, 62.54it/s]Upper bound on the fitting time: 53%|█████▎ | 212/400 [00:03<00:03, 62.54it/s]Upper bound on the fitting time: 55%|█████▍ | 219/400 [00:03<00:02, 62.36it/s]Upper bound on the fitting time: 56%|█████▋ | 226/400 [00:03<00:02, 63.09it/s]Upper bound on the fitting time: 58%|█████▊ | 233/400 [00:04<00:02, 63.86it/s]Upper bound on the fitting time: 60%|██████ | 240/400 [00:04<00:02, 64.31it/s]Upper bound on the fitting time: 62%|██████▏ | 247/400 [00:04<00:02, 62.97it/s]Upper bound on the fitting time: 64%|██████▎ | 254/400 [00:04<00:02, 62.48it/s]Upper bound on the fitting time: 65%|██████▌ | 261/400 [00:04<00:02, 62.66it/s]Upper bound on the fitting time: 67%|██████▋ | 268/400 [00:04<00:02, 62.80it/s]Upper bound on the fitting time: 69%|██████▉ | 275/400 [00:04<00:02, 60.80it/s]Upper bound on the fitting time: 70%|███████ | 282/400 [00:04<00:01, 59.92it/s]Upper bound on the fitting time: 72%|███████▏ | 289/400 [00:04<00:01, 60.81it/s]Upper bound on the fitting time: 74%|███████▍ | 296/400 [00:05<00:01, 61.16it/s]Upper bound on the fitting time: 76%|███████▌ | 303/400 [00:05<00:01, 61.83it/s]Upper bound on the fitting time: 78%|███████▊ | 310/400 [00:05<00:01, 61.94it/s]Upper bound on the fitting time: 79%|███████▉ | 317/400 [00:05<00:01, 63.76it/s]Upper bound on the fitting time: 81%|████████ | 324/400 [00:05<00:01, 64.17it/s]Upper bound on the fitting time: 83%|████████▎ | 331/400 [00:05<00:01, 64.60it/s]Upper bound on the fitting time: 85%|████████▍ | 339/400 [00:05<00:00, 66.93it/s]Upper bound on the fitting time: 87%|████████▋ | 347/400 [00:05<00:00, 67.20it/s]Upper bound on the fitting time: 88%|████████▊ | 354/400 [00:05<00:00, 66.70it/s]Upper bound on the fitting time: 90%|█████████ | 362/400 [00:06<00:00, 68.05it/s]Upper bound on the fitting time: 92%|█████████▏| 369/400 [00:06<00:00, 65.63it/s]Upper bound on the fitting time: 94%|█████████▍| 376/400 [00:06<00:00, 59.79it/s]Upper bound on the fitting time: 96%|█████████▌| 383/400 [00:06<00:00, 59.05it/s]Upper bound on the fitting time: 97%|█████████▋| 389/400 [00:06<00:00, 58.74it/s]Upper bound on the fitting time: 99%|█████████▉| 395/400 [00:06<00:00, 58.55it/s]Upper bound on the fitting time: 100%|██████████| 400/400 [00:06<00:00, 59.61it/s]
Use the .show() method to explore insights about the optimal rank:
pcas.show()⚠️ Note: The best model typically correspond to the largest rank, which may not always be desirable.
The best model can be accessed using the .best_model() method. The selection criterion can be AIC, BIC, or ICL:
best_model = pcas.best_model(criterion="BIC")
print(best_model)A multivariate PlnPCA with 15 principal components.
======================================================================
Loglike Dimension Nb param BIC AIC ICL
-281397.5 500 8895 308044.5386 290292.5 299383.7
======================================================================
* Useful attributes
.latent_variables .latent_positions .coef .covariance .precision .model_parameters .latent_parameters .optim_details
* Useful methods
.transform() .show() .predict() .sigma() .projected_latent_variables() .plot_correlation_circle() .biplot() .viz() .pca_pairplot() .plot_expected_vs_true()
* Additional attributes for PlnPCA are:
None
* Additional methods for PlnPCA are:
None
All individual models in the collection can be accessed with the rank as the key:
pca_5 = pcas[5]
print(pca_5)A multivariate PlnPCA with 5 principal components.
======================================================================
Loglike Dimension Nb param BIC AIC ICL
-331074.75 500 3990 343027.7218 335064.75 340175.22
======================================================================
* Useful attributes
.latent_variables .latent_positions .coef .covariance .precision .model_parameters .latent_parameters .optim_details
* Useful methods
.transform() .show() .predict() .sigma() .projected_latent_variables() .plot_correlation_circle() .biplot() .viz() .pca_pairplot() .plot_expected_vs_true()
* Additional attributes for PlnPCA are:
None
* Additional methods for PlnPCA are:
None
You can also iterate through the collection:
for pca in pcas.values():
print(pca)A multivariate PlnPCA with 3 principal components.
======================================================================
Loglike Dimension Nb param BIC AIC ICL
-363031.38 500 2997 372009.5846 366028.375 370302.42
======================================================================
* Useful attributes
.latent_variables .latent_positions .coef .covariance .precision .model_parameters .latent_parameters .optim_details
* Useful methods
.transform() .show() .predict() .sigma() .projected_latent_variables() .plot_correlation_circle() .biplot() .viz() .pca_pairplot() .plot_expected_vs_true()
* Additional attributes for PlnPCA are:
None
* Additional methods for PlnPCA are:
None
A multivariate PlnPCA with 5 principal components.
======================================================================
Loglike Dimension Nb param BIC AIC ICL
-331074.75 500 3990 343027.7218 335064.75 340175.22
======================================================================
* Useful attributes
.latent_variables .latent_positions .coef .covariance .precision .model_parameters .latent_parameters .optim_details
* Useful methods
.transform() .show() .predict() .sigma() .projected_latent_variables() .plot_correlation_circle() .biplot() .viz() .pca_pairplot() .plot_expected_vs_true()
* Additional attributes for PlnPCA are:
None
* Additional methods for PlnPCA are:
None
A multivariate PlnPCA with 10 principal components.
======================================================================
Loglike Dimension Nb param BIC AIC ICL
-296410.88 500 6455 315748.3268 302865.875 310012.54
======================================================================
* Useful attributes
.latent_variables .latent_positions .coef .covariance .precision .model_parameters .latent_parameters .optim_details
* Useful methods
.transform() .show() .predict() .sigma() .projected_latent_variables() .plot_correlation_circle() .biplot() .viz() .pca_pairplot() .plot_expected_vs_true()
* Additional attributes for PlnPCA are:
None
* Additional methods for PlnPCA are:
None
A multivariate PlnPCA with 15 principal components.
======================================================================
Loglike Dimension Nb param BIC AIC ICL
-281397.5 500 8895 308044.5386 290292.5 299383.7
======================================================================
* Useful attributes
.latent_variables .latent_positions .coef .covariance .precision .model_parameters .latent_parameters .optim_details
* Useful methods
.transform() .show() .predict() .sigma() .projected_latent_variables() .plot_correlation_circle() .biplot() .viz() .pca_pairplot() .plot_expected_vs_true()
* Additional attributes for PlnPCA are:
None
* Additional methods for PlnPCA are:
None
For further details, print the model to explore its methods and attributes.